package org.palmelf.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.palmelf.log.WebLogAppender;
import org.palmelf.service.PhontographService;
import org.palmelf.service.PhontographServiceImpl;

/**
 * Servlet implementation class Test
 */
// @WebServlet("/Test")
public class Test extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8095181906918852254L;

	Logger log = Logger.getLogger(Test.class);

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse response)
			throws ServletException, IOException {
		WebLogAppender wla = new WebLogAppender();
		try {

			String carNum = req.getParameter("carNo");
			System.out.println("车牌号-----------------" + carNum);
			PhontographService phontographService = new PhontographServiceImpl();
			if (carNum != null) {
				// TODO 将传过来的车牌号添加入最后一行数据，它会先拍照在将识别的车牌传过来
				phontographService.updatePhontograph(carNum);
			}
			wla.getWriter().append("访问成功！");
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
